import Vue from 'vue'
import Router from 'vue-router'
import Login from '@/components/Login.vue'
import Register from '@/components/Register.vue'
import Myblog from '@/components/Myblog.vue'
import PostTitle from '@/components/PostTitle.vue'
import BlogDetail from '@/components/BlogDetail.vue'
import MinePage from '@/components/MinePage.vue'
import Resource from '@/components/Resource.vue'
import About from '@/components/About.vue'

Vue.use(Router)

const router = new Router({
  routes: [
    {
      path: '/',
      name: 'Myblog',
      component: Myblog,
    },
    {
      path:'/login',
      name:'Login',
      component:Login
    },
    {
      path:'/register',
      name:'Register',
      component:Register
    },
    {
      path:'/postTitle',
      name:'postTitle',
      component:PostTitle
    },
    {
      path:'/blogDetail/:id',
      name:'BlogDetail',
      component:BlogDetail
    },
    {
      path:'/minepage',
      name:'MinePage',
      component:MinePage
    },
    {
      path:'/resource',
      name:'Resource',
      component:Resource
    },
    {
      path:'/about',
      name:'About',
      component:About
    }
  ]
});

// router.beforeEach((to, from, next) => {
//   //debugger
//   if (to.path === '/') {
//     next();
//   } else {
//     let token = localStorage.getItem('Authorization');
//     if (!token) {
//       next('/');
//     } else {
//       next();
//     }
//   }
// });

export default router;
